package com.hmall.cart;

import com.hmall.api.config.DefaultFeignLogLevelConfig;
import com.hmall.cart.config.LoadBalancerConfig;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClient;
import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClients;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

// 局部配置负载均衡算法，自应用到调用 item-service 上面，调用其他微服务依然是默认的轮询
//@LoadBalancerClient(value = "item-service",configuration = LoadBalancerConfig.class)
/*@LoadBalancerClients({
        @LoadBalancerClient(value = "item-service",configuration = LoadBalancerConfig.class)
})*/
@LoadBalancerClients(defaultConfiguration = LoadBalancerConfig.class)   //全局配置负载均衡算法
@EnableFeignClients(basePackages = "com.hmall.api.clients",defaultConfiguration = DefaultFeignLogLevelConfig.class) //开启openFeign的功能
@MapperScan("com.hmall.cart.mapper")
@SpringBootApplication
public class CartApplication {
    public static void main(String[] args) {
        SpringApplication.run(CartApplication.class, args);
    }

    @Bean
    public RestTemplate restTemplate(){
        return new RestTemplate();
    }
}